<?php namespace Clases;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Usuario
 *
 * @author payo
 */


require_once('arquitectura/AbstractJirach.php');
require_once('Clases/Reporte.php');
require_once('Clases/Alumno.php');
class Docente extends AbstractJIrach{

    public $Nomina;
    public $Nombre;
    public $Tipo;

    public function LlenarDocente($Nomina, $Tipo,$Nombre) {
        $this->Nomina = $Nomina;
        $this->Tipo = $Tipo;
        $this->Nombre = $Nombre;
        $this->insertar();
    }

    public function __construct()
    {
        parent::AbstractJirach();
      
    }

    protected function Comandos() {
        
        $this->id = "Nomina";
        $this->tabla = "`docente`";
        $this->strDelete = "DeleteDocente";
        $this->strInsertar = "InsertarDocente";
        $this->strInsertarId = "InsertarIdDocente";
        $this->strUpdate = "UpdateDocente";
    }
    protected function fillJirach($row) {

        $row = mysql_fetch_row($row);
        $x = -1;
        $this->Nomina = $row[++$x];
        $this->Nombre = utf8_encode($row[++$x]);
        $this->Tipo = $row[++$x];
    }

    public function get($id) {
        $abs = AbstractJirach::getAbstractJirach(new Docente(),$id,$this->tabla,$this->id);
        return $abs;
    }

    public function getAll() {
        $abs = AbstractJirach::getAllAbstract($this->tabla,$this->id,new Docente());
        return $abs;
    }
    public function getAtributos() {
        $lst = array();
        array_push($lst,$this->Nomina);
        array_push($lst,$this->Nombre);
        array_push($lst,$this->Tipo);
        return $lst;
    }
    
    public function getReportesPendientes()
    {
        $value = new Reporte();
        $todos = $value->getAll();
        $lstReportes = array();
        foreach($todos as $reporte)
        {
           $a = new Alumno();
           $alumno = $a->get($reporte->Matricula);
           if($alumno->Nomina == $this->Nomina)
           {
               if($reporte->Atendido == 0)
                   if(!(in_array($reporte, $lstReportes)))
                       array_push($lstReportes, $reporte);
           }
            
        }
        return $lstReportes; 
    }
    
    public function getReportesNoPendientes()
    {
        $value = new Reporte();
        $todos = $value->getAll();
        $lstReportes = array();
        foreach($todos as $reporte)
        {
           $a = new Alumno();
           $alumno = $a->get($reporte->Matricula);
           if($alumno->Nomina == $this->Nomina)
           {
               if($reporte->Atendido == 1)
                   if(!(in_array($reporte, $lstReportes)))
                       array_push($lstReportes, $reporte);
           }
            
        }
        return $lstReportes; 
    }
    
     public function getHistorial()
    {
        $value = new Reporte();
        $todos = $value->getAll();
        $lstReportes = array();
        foreach($todos as $reporte)
        {
            if($reporte->Nomina == $this->Nomina)
                if(!(in_array($reporte, $lstReportes)))
                    array_push($lstReportes, $reporte);  
            
        }
        return $lstReportes; 
    }
    
    public function getAlumnos()
    {
        $value = new Alumno();
        $todos = $value->getAll();
        $lstAlumnos = array();
        foreach($todos as $alumno)
        {
            if($alumno->Nomina == $this->Nomina)
                if(!(in_array($alumno, $lstAlumnos)))
                    array_push($lstAlumnos, $alumno);  
            
        }
        return $lstAlumnos; 
    }
    
}
?>
